<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 12528
  Date: 2022/4/6
  Time: 19:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>业务查询与管理</title>
    <link rel="stylesheet" type="text/css"
          href='<c:url context="${pageContext.request.contextPath}" value="/easyui/themes/default/easyui.css"/>'>
    <link rel="stylesheet" type="text/css"
          href='<c:url context="${pageContext.request.contextPath}" value="/easyui/themes/icon.css"/>'>
    <link rel="stylesheet" type="text/css"
          href='<c:url context="${pageContext.request.contextPath}" value="/easyui/css/demo.css"/>'>
    <script type="text/javascript"
            src='<c:url context="${pageContext.request.contextPath}" value="/easyui/jquery.min.js"/>'></script>
    <script type="text/javascript"
            src='<c:url context="${pageContext.request.contextPath}" value="/easyui/jquery.easyui.min.js"/>'></script>
    <script type="text/javascript"
            src='<c:url context="${pageContext.request.contextPath}" value="/easyui/js/validateExtends.js"/>'></script>
    <script type="text/javascript"
            src='<c:url context="${pageContext.request.contextPath}" value="/easyui/js/easyui-lang-zh_CN.js"/>'></script>

    <script type="text/javascript">
        $(function () {
            //datagrid初始化
            $('#dataList').datagrid({
                title: '已订购业务',
                iconCls: 'icon-more',//图标
                border: true,
                collapsible: true,//是否可折叠的
                fit: false,//自动大小
                method: "get",
                url: "/MSOS/bquery?action=data",
                idField: 'bid',
                singleSelect: true,//是否单选
                pagination: false,//分页控件
                rownumbers: true,//行号
                sortName: 'bid',
                sortOrder: 'ASC',
                remoteSort: false,
                columns: [[
                    {field: 'chk', checkbox: true, width: 50},
                    {field: 'bid', title: '业务编号', width: 80, sortable: true},
                    {field: 'bname', title: '业务名称', width: 200},
                    {field: 'bintro', title: '业务简介', width: 200},
                    {field: 'bimg', title: '业务图片', width: 200},
                    {field: 'bmoney', title: '业务资费', width: 200},
                ]],
                toolbar: "#toolbar"
            });

            //删除
            $("#delete").click(function () {
                var selectRow = $("#dataList").datagrid("getSelected");
                if (selectRow == null) {
                    $.messager.alert("消息提醒", "请选择业务!", "warning");
                } else {
                    var businessid = selectRow.bid;
                    $.messager.confirm("消息提醒", "将取消与【" + selectRow.bname + "】业务相关的所有数据，确认继续？", function (r) {
                        if (r) {
                            $.ajax({
                                type: "delete",
                                url: "/MSOS/bquery?bid=" + businessid,
                                success: function (msg) {
                                    if (msg.status == 200) {
                                        $.messager.alert("消息提醒", msg.msg, "info");
                                        //刷新表格
                                        $("#dataList").datagrid("reload");
                                        $("#dataList2").datagrid("reload");
                                        //取消已选中的所有行
                                        $("#dataList").datagrid("unselectAll");
                                    } else {
                                        $.messager.alert("消息提醒", msg.msg, "warning");
                                        return;
                                    }
                                }
                            });
                        }
                    });
                }
            });



            //datagrid初始化
            $('#dataList2').datagrid({
                title: '办理业务',
                iconCls: 'icon-more',//图标
                border: true,
                collapsible: false,//是否可折叠的
                fit: true,//自动大小
                method: "get",
                url: "/MSOS/bquery?action=data_from_manager",
                idField: 'bid',
                singleSelect: true,//是否单选
                pagination: false,//分页控件
                rownumbers: true,//行号
                sortName: 'bid',
                sortOrder: 'ASC',
                remoteSort: false,
                columns: [[
                    {field: 'chk', checkbox: true, width: 50},
                    {field: 'bid', title: '业务编号', width: 200, sortable: true},
                    {field: 'bname', title: '业务名称', width: 200},
                    {field: 'bintro', title: '业务简介', width: 200},
                    {field: 'bimg', title: '业务图片', width: 200},
                    {field: 'bmoney', title: '业务资费', width: 200},
                ]],
                toolbar: "#toolbar2"
            });

            //办理业务
            $("#add").click(function () {
                var selectRow = $("#dataList2").datagrid("getSelected");
                if (selectRow == null) {
                    $.messager.alert("消息提醒", "请选择业务!", "warning");
                } else {
                    var businessid = selectRow.bid;
                    $.messager.confirm("消息提醒", "将办理【" + selectRow.bname + "】业务，确认继续？", function (r) {
                        if (r) {
                            $.ajax({
                                type: "post",
                                url: "/MSOS/bquery?bid=" + businessid,
                                success: function (msg) {
                                    if (msg.status == 200) {
                                        $.messager.alert("消息提醒", msg.msg, "info");
                                        //刷新表格
                                        $("#dataList").datagrid("reload");
                                        $("#dataList2").datagrid("reload");
                                        //取消已选中的所有行
                                        $("#dataList").datagrid("unselectAll");
                                    } else {
                                        $.messager.alert("消息提醒", msg.msg, "warning");
                                        return;
                                    }
                                }
                            });
                        }
                    });
                }
            });

        });
    </script>
</head>
<body>
<!-- 已订购业务 -->
<table id="dataList" cellspacing="0" cellpadding="0">
</table>

<!-- 业务办理 -->
<table id="dataList2" cellspacing="0" cellpadding="0">
</table>

<!-- 工具栏 -->
<div id="toolbar">
    <div><a id="delete" href="javascript:;" class="easyui-linkbutton"
            data-options="iconCls:'icon-some-delete',plain:true">取消业务</a></div>
</div>

<!-- 工具栏2 -->
<div id="toolbar2">
<div><a id="add" href="javascript:;" class="easyui-linkbutton"
        data-options="iconCls:'icon-some-delete',plain:true">办理业务</a></div>
</div>

</body>
</html>
